home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 352_01.zip / VLPARSES.CPP < prev    next >
C/C++ Source or Header  |  1993-04-10  |  804b  |  25 lines

  1. // VlistParseString () -  parse a String into a Vlist.
  2. //        params: Vlist& v is list to hold output (=parsed string)
  3. //                char* s is input String to parse ( or may use String& s )
  4. //        returns: number of token words found.    
  5. //        NOTE this code checks for 2 consecutive tokens, does not add blanks.
  6. #include "dblib.h"
  7.  
  8. int VlistParseString ( Vlist& V, char *s, char *sepchars )
  9.     {
  10.     int count =0;
  11.     if ( !( s == NULL || s[0] == 0 ) )
  12.         {
  13.         String *Sptr;
  14.         String Str = s;
  15.         while ( Str != NULL )
  16.             {
  17.             Sptr = Str.tokenize (sepchars);        // tokenize() returns a String*
  18.             if ( (*Sptr).len() > 0 )    V.push ( (char*)(*Sptr) );        
  19.             delete Sptr;                        //... which must be deleted    
  20.             ++count;
  21.             }
  22.         }
  23.     return count;
  24.     }
  25. //------------------- end of VLPARSES.CPP ------------------------